﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using DevCow.Mashups;


namespace DevCow.Mashups.Blocks.Samples
{
    public class NameArrayBlock
    {
        public object MyArray()
        {
            var x = new MyInteralArray();
            return x;
        }

        internal class MyInteralArray : List<string>
        {
            public MyInteralArray()
            {
                this.Add("Matt");
                this.Add("Brendon");
                this.Add("Heidi");
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder();
                foreach (string l in this)
                {
                    sb.AppendLine(l);
                }

                return sb.ToString();
            }
        }
    }

    public class NameDateArrayBlock
    {
        public object MyArray()
        {
            var x = new MyInteralArray2();
            return x;
        }

        internal class MyInteralArray2 : DataTable
        {
            public MyInteralArray2()
            {
                this.Columns.Add("FirstName");
                this.Columns.Add("BirthDate");

                DataRow dr = this.NewRow();
                dr["FirstName"] = "Matt";
                dr["BirthDate"] = DateTime.Now;
                this.Rows.Add(dr);

                dr = this.NewRow();
                dr["FirstName"] = "Brendon";
                dr["BirthDate"] = DateTime.Now.AddDays(5);
                this.Rows.Add(dr);

                dr = this.NewRow();
                dr["FirstName"] = "Heidi";
                dr["BirthDate"] = DateTime.Now.AddDays(-10);
                this.Rows.Add(dr);
            }

            //public override string ToString()
            //{
            //    StringBuilder sb = new StringBuilder();
            //    foreach (string l in this)
            //    {
            //        sb.AppendLine(l);
            //    }

            //    return sb.ToString();
            //}
        }
    }

    public class NameDateArrayBlock2
    {
        public object MyArray()
        {
            List<MyInteralArray3> j = new List<MyInteralArray3>();
            j.Add(new MyInteralArray3 { FirstName = "Matt", Birthdate = DateTime.Now });
            j.Add(new MyInteralArray3 { FirstName = "Brendon", Birthdate = DateTime.Now.AddDays(5) });
            j.Add(new MyInteralArray3 { FirstName = "Heidi", Birthdate = DateTime.Now.AddDays(-10) });

            return j;
        }

        internal class MyInteralArray3
        {
            public string FirstName;
            public DateTime Birthdate;


            public override string ToString()
            {
                return String.Format("{0} has a birthday on {1}", FirstName, Birthdate.ToShortDateString());
            }
        }
    }

    public class HelloWorldNameBlock
    {
        public string HelloWorld(string name)
        {
            return "Hello World " + name;
        }
    }

    public class HeidiBlock
    {
        public string MyName()
        {
            return "Heidi";
        }
    }

    public class HelloWorldBlock
    {
        public string HelloWorld()
        {
            return "hello world!";
        }
    }

    public class MyBlock2
    {
        public string NoMyMethod()
        {
            return "show again world!";
        }
    }

    public class MattBlock
    {
        public string TransformString()
        {
            string strTransform = "!looc si ttaM";
            return Reverse(strTransform);
        }

        private string Reverse(string str)
        {
            int len = str.Length;
            char[] arr = new char[len];

            for (int i = 0; i < len; i++)
            {
                arr[i] = str[len - 1 - i];
            }

            return new string(arr);
        }
    }

    public class BirthdayBlock
    {
        public string Birthday(string name, DateTime date)
        {
            return name + " Your birthday is " + date.ToShortDateString();
        }
    }

    public class IntBlock
    {
        public int NumberFive()
        {
            return 5;
        }
    }

    public class BooleanBlock
    {
        public bool TrueValue()
        {
            return true;
        }
    }

}